﻿using Android_Helper.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Android_Helper.java
{
    class ExcelTitleToMap
    {
        public static string DictionaryToMap(Dictionary<int, string> dirs) {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.AppendLine("Map<String, Int> map= new TreeMap();");
            foreach (var item in dirs)
            {
                stringBuilder.AppendLine(string.Format("map.Add('{0}': {1}); // {0}", item.Value, item.Key + 1));
            }
            stringBuilder.AppendLine("");
            return stringBuilder.ToString();
        }

        public static string DictionaryToEntity(Dictionary<int, string> dirs)
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.AppendLine("");
            foreach (var item in dirs)
            {
                stringBuilder.AppendLine(string.Format("/**"));
                stringBuilder.AppendLine(string.Format("*{0}", item.Value, item.Key + 1));
                stringBuilder.AppendLine(string.Format("**/"));
                stringBuilder.AppendLine(string.Format("@Column(nullable = false, columnDefinition = \"varchar(50) comment '{0}' default '' \")", item.Value));
                stringBuilder.AppendLine(string.Format("private String {0};", NameUtils.LowercaseUnderlineToCammle(NameUtils.HanZiToLowercaseUnderline(item.Value))));
                stringBuilder.AppendLine("");
            }
            stringBuilder.AppendLine("");
            return stringBuilder.ToString();
        }
    }
}
